import router from './router/index'
import store from '@/store/index.js'
router.beforeEach(async(to, from, next) => {
  if (['/login', '/learnVuex', '/404'].includes(to.path)) {
    return next()
  }
  if (store.state.user.token) {
    if (!store.state.user.userInfo.userId) {
      await store.dispatch('user/getUserInfo')
    }
    next()
  } else {
    next('/login')
  }
})
router.afterEach((to, from) => {

})
